﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


using Microsoft.Practices.Prism.PubSubEvents;

using System.Diagnostics;
using System.Globalization;
using System.Windows;
using EventAggregationModule;
using EventAggregationModule.Models;

namespace Product_2_2
{
    public class ActivityPresenter
    {
        private string _number;
        private string _year;
        private string _month;
        private string _day;
        //   private string _number2;

        private IEventAggregator eventAggregator;
        private SubscriptionToken subscriptionToken;

        public ActivityPresenter(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;
            LotNumberEvent lotNumberEvent = eventAggregator.GetEvent<LotNumberEvent>();


            if (subscriptionToken != null)
            {
                lotNumberEvent.Unsubscribe(subscriptionToken);
            }
            subscriptionToken = lotNumberEvent.Subscribe(LotNumberEventHandler, ThreadOption.UIThread, false);
        }

        public void LotNumberEventHandler(LotNumber lotnumber)
        {
            Debug.Assert(View != null);
            View.SetLotNumber(lotnumber.Number);
           // View.SetDate(lotnumber.Year, lotnumber.Month, lotnumber.Day);
        }

        public IActivityView View { get; set; }

        public string Number
        {
            get
            {
                return _number;
            }
            set
            {
                _number = value;
            }
        }

        //public string Month
        //{
        //    get
        //    {
        //        return _month;
        //    }
        //    set
        //    {
        //        _month = value;
        //    }
        //}

        //public string Year
        //{
        //    get
        //    {
        //        return _year;
        //    }
        //    set
        //    {
        //        _year = value;
        //    }
        //}

        //public string Day
        //{
        //    get
        //    {
        //        return _day;
        //    }
        //    set
        //    {
        //        _day = value;
        //    }
        //}

    }
}
